package com.zs.client;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

public class Client {
	public static void main(String[] args) {
		Socket socket = null;
		OutputStream out = null;
		InputStream in=null;
		try {
			socket = new Socket();
			socket.connect(new InetSocketAddress(8090));
			out = socket.getOutputStream();
			in=socket.getInputStream();
			out.write("a".getBytes());
			System.out.println("send ...end");
			
			System.out.println("recevice ...response");
			byte[] b=new byte[1024];
			int len=0;
			while((len=in.read(b))!=-1){
				System.out.println(new String(b,0,len));
			}
			
		} catch (Exception e) {
			e.printStackTrace();

		}finally{
			try {
				if (socket != null) {
					socket.close();
				}
				if (out != null) {
					out.close();
				}
				if(in!=null){
					in.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		

	}

}
